package com.zlzxm.sorting.ui.activity

import android.view.View
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.zlzxm.sorting.databinding.AcSettingBinding
import com.zlzxm.sorting.ui.fragment.*
import com.zlzxm.sorting.util.ui.manager.AbsAcBase

class AcSetting : AbsAcBase(){

    val binding by lazy {

        AcSettingBinding.inflate(layoutInflater)
    }

    override fun initBinding(): ViewBinding? {

        return binding
    }

    override fun initViewModel() {


    }

    override fun initView() {

//        fullScreenMode()

        val pages = mutableListOf<Fragment>()
        pages.add(FmSettingPrint())
        pages.add(FmSettingWeight())
        pages.add(FmSettingSize())
        pages.add(FmSettingProduct())
        pages.add(FmSettingBase())

        binding.viewpage.isUserInputEnabled = false
        binding.viewpage.adapter = object  : FragmentStateAdapter(this){

            override fun getItemCount(): Int {

                return  pages.size
            }

            override fun createFragment(position: Int): Fragment {
                return pages[position]
            }

        }

        selectIndex(binding.llPrint)

        binding.llPrint.setOnClickListener{

            selectIndex(it)
            binding.viewpage.currentItem = 0
        }
        binding.llWeight.setOnClickListener{

            selectIndex(it)
            binding.viewpage.currentItem = 1
        }
        binding.llSize.setOnClickListener{

            selectIndex(it)
            binding.viewpage.currentItem = 2
        }
        binding.llProduct.setOnClickListener{

            selectIndex(it)
            binding.viewpage.currentItem = 3
        }
        binding.llBase.setOnClickListener{

            selectIndex(it)
            binding.viewpage.currentItem = 4
        }


    }

    override fun initData() {
    }


    fun selectIndex(view: View){

        binding.llPrint.isSelected = false
        binding.llWeight.isSelected = false
        binding.llSize.isSelected = false
        binding.llProduct.isSelected = false
        binding.llBase.isSelected = false
        view.isSelected = true


    }

}